<!--新增预算管理页面-->
<template>
  <div class="container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>新增预算</span>
        <el-button style="float: right; padding: 3px 0" type="text" @click="back">返回</el-button>
      </div>
<!--      表单数据-->
      <el-form ref="addForm" v-model="addGoodForm" label-width="120px">
        <el-form-item label="修建地址">
          <el-input v-model="addGoodForm.buildAddress" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="修建日期">
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="addGoodForm.buildDate"
            type="date"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="修建类型">
          <el-select v-model="addGoodForm.buildType" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="冷库类型">
        <el-select v-model="addGoodForm.category" placeholder="请选择">
          <el-option
            v-for="item in catgoryOption"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
        <el-form-item label="冷库高">
          <el-input v-model="addGoodForm.height" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="冷库长">
          <el-input v-model="addGoodForm.length" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="冷库宽">
          <el-input v-model="addGoodForm.width" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="冷库体积">
          <el-input v-model="addGoodForm.volume" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="用户手机号">
          <el-input v-model="addGoodForm.mobile" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit('addForm')">添加</el-button>
          <el-button @click="back">取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import { addBudgetList } from '@/api/budget'

export default {
  name: "addBudget",
  data(){
    return{
      addGoodForm:{},
      options: [{
        value: 1,
        label: '自建'
      }, {
        value: 2,
        label: '农业补贴'
      }],
      catgoryOption: [{
        value: 1,
        label: '保鲜库'
      }, {
        value: 2,
        label: '冷冻库'
      },
        {
          value: 3,
          label: '气调库'
        },
        {
          value: 4,
          label: '功能性冷库'
        }
      ],
    }
  },
  methods:{
    //返回
    back(){
      this.$store.dispatch('tagsView/delVisitedView', this.$route)
      this.$router.push('/offer/budget')
    },
    onSubmit(){
      addBudgetList({
        buildAddress:this.addGoodForm.buildAddress,
        buildDate:this.addGoodForm.buildDate,
        buildType:this.addGoodForm.buildType,
        category:this.addGoodForm.category,
        height:this.addGoodForm.height,
        length:this.addGoodForm.length,
        mobile:this.addGoodForm.mobile,
        volume:this.addGoodForm.volume,
        width:this.addGoodForm.width
      }).then(res=>{
        this.$message.success('添加成功')
        this.back()
      }).catch(res=>{
      })
    }
  }
}
</script>

<style scoped lang="scss">
.container{
  padding: 20px;
}
</style>
